package com.shuyun.cloud.gateway;

//import com.shuyun.cloud.gateway.filter.RequestBodyOperationFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

/**
 * @description:
 *      https://www.fangzhipeng.com/springcloud/2018/11/06/sc-f-gateway1.html
 *
 * @author: shuai.chen@shuyun.com
 * @date: 2021/6/22 3:39 下午
 */
@SpringBootApplication
public class GatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }

//    @Bean
//    public RouteLocator myRoutes(RouteLocatorBuilder builder) {
//        String httpUri = "http://httpbin.org";
//        // 根据具体的 请求规则p 由具体的route去处理，filters是各种过滤器，对请求和响应做各种判断和修改
//        return builder.routes()
//                .route("1", p -> p
//                        .path("/get")
//                        .filters(f -> f.addRequestHeader("Hello", "World"))
//                        // 实际访问：http://httpbin.org/get
//                        .uri(httpUri))
//                .route("2", p -> p.path("/api/members").filters(f -> f.filter(new RequestBodyOperationFilter()))
//                        .uri("http://127.0.0.1:8081/api/members"))
//                .build();
//    }

}
